package LsL::Mason;

use strict;
use HTML::Mason::ApacheHandler ();

{
#  # install exported functions
  package HTML::Mason::Commands;
  use Lingua::EN::NameCase qw(nc);
}

my $ah;

$ah = HTML::Mason::ApacheHandler->new
        ( comp_root     => '/srv/www/www',
          data_dir      => '/srv/www/mason_data',
          allow_globals => [qw($PUser $PSession)],
          args_method   => 'mod_perl',
          error_mode    => $LsL::Config::ERROR_MODE,
        );

sub handler {
  my ($r) = @_;

  return -1 unless $ah;

  # check for custom handler
  #my $script = LsL::Group::get_script($r->uri);
  
  my $return = eval { $ah->handle_request($r) };

  # check for error
  if (my $err = $@) {
    $r->pnotes( error => $err );
    $r->filename( $r->document_root . '/lib/server_error' );

    return $ah->handle_request($r);
  }

  return $return;
}

1;
